//
//  GuaListHeaderView.swift
//  jiaoyi
//
//  Created by wjk on 2018/8/15.
//  Copyright © 2018年 wjk. All rights reserved.
//

import UIKit
import SnapKit

class GuaListHeaderView: UIView {

    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */
    
    private lazy var titles:[String] = {
       return ["当前交易节","当前状态","剩余时间","系统时间"]
    }()
    
    private lazy var topBgView : UIView = {
        var view = UIView(frame: CGRect(x: 0, y: 0, width: deviceWidth(), height: 155))
        view.backgroundColor = baseColor()
        return view
    }()
     lazy var label: UILabel = {
        let label = UILabel()
        label.text = "1月15日竞价销售"
        label.textColor = UIColor.white
        label.frame.origin.y = 20
        label.frame.origin.x = 20
        label.font = UIFont.systemFont(ofSize: 13)
//        label.frame.size.width = 200
//        label.isUserInteractionEnabled = true
//        label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapLabel(_:))))
//        label.sizeToFit()
        return label
    }()
    
     lazy var xxLabel: UILabel = {
        let label = UILabel()
        
        label.textColor = .white
        label.font = UIFont.systemFont(ofSize: 14)
        label.numberOfLines = 2
        
        
        return label
    }()
    
    private lazy var buttonView: UIView = {
        
        var view = UIView()
        view.backgroundColor = .white
        
        return view
    }()
    
    
     lazy var label1: UILabel = {
        let label1 = UILabel()
        label1.textColor = kRGBColorFromHex(rgbValue: 0x333333)
        label1.font = UIFont.systemFont(ofSize: 12)
        label1.text = titles[0]
//        buttonView.addSubview(label1)
        return label1
    }()
    
     lazy var label2: UILabel = {
        let label2 = UILabel()
        label2.textColor = kRGBColorFromHex(rgbValue: 0x333333)
        label2.font = UIFont.systemFont(ofSize: 12)
        label2.text = titles[1]
//        buttonView.addSubview(label2)
        return label2
    }()
    
     lazy var label3: UILabel = {
        let label3 = UILabel()
        label3.textColor = kRGBColorFromHex(rgbValue: 0x333333)
        label3.font = UIFont.systemFont(ofSize: 12)
        label3.text = titles[2]
        return label3
    }()
    
     lazy var label4: UILabel = {
        let label4 = UILabel()
        label4.textColor = kRGBColorFromHex(rgbValue: 0x333333)
        label4.font = UIFont.systemFont(ofSize: 12)
        label4.text = titles[3]
        
        return label4
    }()
    
    
     lazy var label11: UILabel = {
        let label1 = UILabel()
        label1.textColor = kRGBColorFromHex(rgbValue: 0x222222)
        label1.font = UIFont.systemFont(ofSize: 14)
        label1.text = "--"
        label1.numberOfLines = 2
        label1.sizeToFit()
        //        buttonView.addSubview(label1)
        return label1
    }()
    
     lazy var label22: UILabel = {
        let label2 = UILabel()
        label2.textColor = kRGBColorFromHex(rgbValue: 0x222222)
        label2.font = UIFont.systemFont(ofSize: 14)
        label2.text = "--"
        //        buttonView.addSubview(label2)
        return label2
    }()
    
     lazy var label33: UILabel = {
        let label3 = UILabel()
        label3.textColor = kRGBColorFromHex(rgbValue: 0x222222)
        label3.font = UIFont.systemFont(ofSize: 14)
        label3.text = "--"
        return label3
    }()
    
     lazy var label44: UILabel = {
        let label4 = UILabel()
        label4.textColor = kRGBColorFromHex(rgbValue: 0x222222)
        label4.font = UIFont.systemFont(ofSize: 14)
        label4.text = "--"
        label4.numberOfLines = 2
        return label4
    }()
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = tableviewBackgroundColor()
        addSubview(topBgView)
        addSubview(label)
        addSubview(xxLabel)
        addSubview(buttonView)
        
        
        xxLabel.text = "test \n test2"
        xxLabel.snp.makeConstraints({ (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(-20)
        })
        
        
        buttonView.snp.makeConstraints({ (make) in
            make.right.equalToSuperview().offset(-8)
            make.left.equalToSuperview().offset(8)
            make.bottom.equalToSuperview().offset(-20)
            make.height.equalTo(82)
        })
        
        buttonView.addSubview(label1)
        buttonView.addSubview(label2)
        buttonView.addSubview(label3)
        buttonView.addSubview(label4)
        
        label1.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.top.equalToSuperview().offset(22)
        }
        label2.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(22)
            make.left.equalTo(label1.snp.right)
            make.width.equalTo(label1.snp.width)
        }
        
        label3.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(22)
            make.left.equalTo(label2.snp.right)
            make.width.equalTo(label1.snp.width)
        }
        
        label4.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(22)
            make.left.equalTo(label3.snp.right)
            make.width.equalTo(label1.snp.width)
            make.right.equalToSuperview()
        }
        
        buttonView.addSubview(label11)
        buttonView.addSubview(label22)
        buttonView.addSubview(label33)
        buttonView.addSubview(label44)
        
        label.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(20)
            make.top.equalTo(self).offset(20)
            make.width.equalTo(250)
        }
        
        label11.snp.makeConstraints { (make) in
            make.left.equalTo(label1)
            make.width.equalTo(self)
            make.top.equalTo(label1.snp.bottom).offset(10)
        }
        
        label22.snp.makeConstraints { (make) in
            make.left.equalTo(label2)
            make.top.equalTo(label2.snp.bottom).offset(10)
        }
        
        label33.snp.makeConstraints { (make) in
            make.left.equalTo(label3)
            make.top.equalTo(label3.snp.bottom).offset(10)
        }
        
        label44.snp.makeConstraints { (make) in
            make.left.equalTo(label4)
            make.top.equalTo(label4.snp.bottom).offset(10)
        }
        
        
    }
    
    
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.frame = CGRect(x: 0, y: 0, width: deviceWidth(), height: 221)
//        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        self.frame = CGRect(x: 0, y: 0, width: deviceWidth(), height: 221)
    }
}
